package com.itheima_04;

import java.util.Arrays;

public class IntegerDemo {
    public static void main(String[] args) {
        //定义一个字符串
        String s = "91 27 46 38 50";
        //拆分字符串保存到String数组中
        String[] strArray = s.split(" ");

        int[] arr = new int[strArray.length];

        for (int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(strArray[i]);
        }

        //对int数组排序
        Arrays.sort(arr);

        //对数组中的数据进行拼接
        StringBuilder sb = new StringBuilder();
        for (int i =0; i <arr.length; i++){
            if (i == arr.length-1){
                sb.append(arr[i]);
            } else {
                sb.append(arr[i]).append(" ");
            }
        }

        String result = sb.toString();

        System.out.println(result);


    }
}
